home *** CD-ROM | disk | FTP | other *** search
-
- const DIALOG = document.getElementById('yoono-dialog-goodbye');
- const LOGIN = document.getElementById('yoono-goodbye-currentlogin');
- const SUCCESSDELETED = document.getElementById('yoono-goodbye-success-deleted');
- const SUCCESSKEPT = document.getElementById('yoono-goodbye-success-kept');
- const CONNECTERROR = document.getElementById('yoono-goodbye-connecterror');
- const INVALIDUSER = document.getElementById('yoono-goodbye-invaliduser');
-
- const OPTION = document.getElementById('yoono-goodbye-option');
- const REASON = document.getElementById('yoono-goodbye-reason');
- const REASONCONTAINER = document.getElementById('reason-container');
-
- const DECK = document.getElementById('goodbye-deck');
- const STRBUNDLE = document.getElementById("yoono-strings");
- const COMMENTS = document.getElementById("comments");
-
- var returnObject;
- var serverUrl = '';
-
- var USER = YOONO_CMPT.getUserCredential();
-
- function initGoodbye() {
- returnObject = window.arguments[0];
- // If uninstall already validated and then canceled before restarting, prefs are gone...
- try {
- // If no user or anonymous, hide the upper part that offers to delete the account
- if(!USER || USER.anonymous) {
- // an 'observes' attribute observing the radiogroup will hide all what we need to hide
- OPTION.hidden = true;
- OPTION.value='delete';
- }
- serverUrl = YNPREFBRANCH.getCharPref('serverurl');
- LOGIN.value = USER.login;
- OPTION.value='keep';
- centerWindow();
- // Get different reasons to display
- var reasonsUrl = YNPREFBRANCH.getCharPref('messages.path');
- reasonsUrl += STRBUNDLE.getString('goodbye.reasons.filename');
- REASON.value = -1; // No reason loaded
- var result = YOONO_CMPT.sendRequest(reasonsUrl, 'GET', 'sync', '', null);
- // show form
- if('' != result[1]) {
- var text = '';
- var id = '';
- var reason = null;
- var xml = result[1];
- for (var i=0; i < xml.reason.length(); i++) {
- text = xml.reason[i].@text.toString();
- id = xml.reason[i].@id.toString();
- // Beware, xml.reason[i].@default gives a syntax error in FF1.5 while is ok in FF2
- defaultReason = xml.reason[i].@['default'];
- defaultReason = defaultReason.toString();
- reason = document.createElement('radio');
- reason.setAttribute('label', text);
- reason.setAttribute('value', id);
- if('true' == defaultReason) {
- reason.setAttribute('selected', true);
- REASON.value = id;
- }
- REASON.appendChild(reason);
- }
- if(REASON.childNodes.length) {
- REASONCONTAINER.removeAttribute('collapsed');
- }
- }
- sizeToContent();
- } catch (e) {
- YOONO_LOG.exception(e);
- returnObject.value = true;
- window.arguments[0] = returnObject;
- window.close();
- }
- }
-
- function validateForm() {
- clearWarnings();
- DIALOG.buttons="accept";
- DECK.selectedIndex = 1;
- var option = OPTION.value;
- var reason = REASON.value;
- var remove = ('delete'==option)?true:false;
- // build the script to send to server when uninstalling
- returnObject.script = <server-script version="1.0"/>;
- // If no user account, make sure remove is set to false so that server does not send an error back
- if(!USER) remove = false;
- // If anonymous, always remove
- if(USER.anonymous) remove = true;
- var context = <context/> ;
- context.appendChild(<user-id>{USER.userId}</user-id>);
- if (YOONO_YEXTIF.methods.isStandalone())
- context.appendChild(<version>{YOONO_YEXTIF.methods.getVersion()}</version>);
- else
- context.appendChild(<version>{YOONO_UTILS.getExtensionVersion()}</version>);
- if (YOONO_YEXTIF.methods.isStandalone())
- context.appendChild(<client>dsk</client>);
- else
- context.appendChild(<client>xpi</client>);
- returnObject.script.appendChild(context);
- var child=null;
- if(reason >= 0) {
- child = <uninstall remove-user-account={remove} reason-id={reason}/>
- } else {
- child = <uninstall remove-user-account={remove}/>
- }
- var commentsModified = COMMENTS.getAttribute('typed');
- if('true' == commentsModified) {
- var comments = COMMENTS.value;
- comments = comments.substr(0, 499);
- child.appendChild(COMMENTS.value);
- }
- returnObject.script.appendChild(child);
- setHappyExit();
- return false; // not closing window, user must click again, so that he can read messages
- }
-
- function setHappyExit() {
- DIALOG.buttons="extra1";
- sizeToContent();
- // Make sure true is returned if user closes window with X button
- returnObject.value = true;
- window.arguments[0] = returnObject;
- cancelForm = validOk;
- }
-
- function cancelForm() {
- returnObject.value = false;
- window.arguments[0] = returnObject;
- window.close();
- }
-
- function validOk() {
- window.close();
- }
-
- function empty(textbox) {
- var typed = textbox.getAttribute('typed') || 'false';
- if('false' == typed) {
- textbox.setAttribute('typed', 'true');
- textbox.value = '';
- }
- }
-